package com.dhecp.project.base.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhecp.core.constant.DataFiltering;
import com.dhecp.core.utils.PageUtils;
import com.dhecp.project.base.domain.CompanyInfo;
import com.dhecp.project.base.mapper.CompanyInfoMapper;
import com.dhecp.project.base.service.CompanyInfoService;
import com.dhecp.project.system.service.SysDictionaryForFieldService;

/**
 * 
 * @author DH-Xxj
 * @version 2019年11月4日
 */

@Service
public class CompanyInfoServiceImpl implements CompanyInfoService {

	@Autowired
	private CompanyInfoMapper companyInfoMapper;
	
	@Autowired
	private SysDictionaryForFieldService dictionaryForFieldService;

	/**
	 * 通过公司编码【vId】查询公司信息
	 * @param params
	 * @return CompanyInfo - 实体
	 * @throws Exception
	 * @author DH-Xxj
	 */
	@Override
	public CompanyInfo queryCompanyInfoByVId(Map<String, Object> params) throws Exception {
		if (params.get("vId") == null || params.get("vId") == ""){
    		throw new RuntimeException("请提供必要的参数[公司编码]：vId"); 
    	}
		return companyInfoMapper.findCompanyInfoByVId(params.get("vId").toString());
	}
	
	/**
	 * 按条件查询公司信息
	 * @param params
	 * @param nowherestr 若存在（任意值），表示不进行条件过滤
	 * @param nodatascode 若存在（任意值），表示不进行数据权限控制
	 * @return List-CompanyInfo
	 * @throws Exception
	 * @author DH-Xxj
	 */
	@Override
    public List<CompanyInfo> queryCompanyInfoList(Map<String, Object> params) throws Exception {
//        params.put(DataFiltering.TABLE_ALIAS, "t1");	//查询表别名
        params.put(DataFiltering.DATA_WHERE, dictionaryForFieldService.getWhereStr(params));		//常规查询条件SQL语句
        params.put(DataFiltering.DATA_SCODE, dictionaryForFieldService.getDataScode(params));		//数据权限查询条件SQL语句
        PageUtils.startPage();
        return companyInfoMapper.findCompanyInfoList(params);
    }
    
}
